/*
 *  MultipleSequence.cpp
 *  MultipleSequence
 *
 *  Created by ~max~ on 22/03/11.
 *  Copyright 2011 Università di Padova. All rights reserved.
 *
 */

#include "MultipleSequence.h"
// Constructor that set upgmaTree parameter with the Upgma tree calculate in UpgmaCluster class
MultipleSequence::MultipleSequence (upgma* u)
{
	Upgma= u;
	upgmaTree= Upgma->getResult(); 

	
}



UpgmaCluster* MultipleSequence::altezzaAlbero(UpgmaCluster* nodo, vector<int> C) // search node with maximum depth
{
	int left=0, right=0;
	if(!nodo->left && !nodo->right) return nodo;
	
	// control the maximum depth from the current node
	if(nodo->left) left= altezzaAlbero(nodo->left);
	if(nodo->right) right= altezzaAlbero(nodo->right);
	if(left>=right) // if the depth of left is >= of the right, we go left and save the choice
	{
		C.push_back(0);
		findLastNode(nodo->left, C);
	}
	else 
	{
		C.push_back(1);
		findLastNode(nodo->right,C);
	}
}

// Ritorna l'altezza
int MultipleSequence::altezzaAlbero(UpgmaCluster* nodo)
{
	if(!nodo) return 0;
	int a= altezzaAlbero(nodo->left);
	int b= altezzaAlbero(nodo->right);
	if(a>b) return a+1;
	else return b+1;
}

// Return the number of the sequence
int MultipleSequence::numberOfSequence(UpgmaCluster* nodo)
{
	if(!nodo) return 0;
	return 1+numberOfSequence(nodo->left)+numberOfSequence(nodo->right);
}

int MultipleSequence::calcolateScore()
{
	int MseqLeft=numberOfSequence(upgmaTree->left);
	int NseqRight=numberOfSequence(upgmaTree->right);
	
	int fraction= 1/(MseqLeft+NseqRight);
	
	
	
	
}